package com.only4play.practice.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.only4play.codegen.support.constants.BaseEnum;

import java.util.Optional;

/**
 * 前端的字典类型选择为【下拉列表】表示字典类型的值从下拉框中拿，选择为【http调用】
 * 则表示从指定的url中拿字典数据
 */
public enum DictType implements BaseEnum<DictType> {

  SELECT_LIST(1, "下拉列表"),
  HTTP_INVOKE(2,"http调用")
  ;

  DictType(Integer code, String name) {
    this.code = code;
    this.name = name;
  }

  @EnumValue
  private Integer code;
  private String name;

  @Override
  public Integer getCode() {
    return this.code;
  }

  @Override
  public String getName() {
    return this.name;
  }

  public static Optional<DictType> of(Integer code) {
    return Optional.ofNullable(BaseEnum.parseByCode(DictType.class, code));
  }

}
